home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 December / DPPCPRO1205.ISO / Essentials / Programming / Basic4GL / Setup Basic4GL v2.3.1.exe / $INSTDIR / Programs / Koch02.gb < prev    next >
Encoding:
Text File  |  2005-07-29  |  1.4 KB  |  87 lines

  1. ' Von Bon Koch
  2. ' Written by Scott Brosious
  3. const width = 640, height = 480  
  4.  
  5. dim a: a = 84 ' Start using this angle
  6. dim nops
  7. nops = 256   
  8. dim mainloop
  9. mainloop = 20
  10. dim ang(339) 
  11.  
  12. ang(0) = 0
  13. ang(1) = 72
  14. ang(2) = 288
  15. ang(3) = 0
  16.  
  17. dim p,s,f,i,j
  18.  
  19. p = 4 ' Point to where you are at
  20.  
  21. s = 0:f = 3 ' Start and Finish where you are calculating sets of 4
  22.  
  23. for j = 0 to mainloop
  24. for i = s to f
  25.  
  26. ang(p) = ang(i)
  27. ang(p + 4) = ang(i) + 72
  28. ang(p + 8) = ang(i) - 72
  29. ang(p + 12) = ang(i)
  30.  
  31. p = p + 1
  32.  
  33. next
  34.  
  35. p = p + 12
  36.  
  37. s = s + 4
  38. f = s + 3
  39.  
  40. next
  41.  
  42. ' Set 2D mode
  43. glMatrixMode (GL_PROJECTION)
  44. glLoadIdentity ()
  45. glOrtho (0, width, 0, height, -1, 1)
  46. glMatrixMode (GL_MODELVIEW)
  47. glDisable (GL_DEPTH_TEST)
  48.  
  49. ' Clear screen
  50. glClear (GL_COLOR_BUFFER_BIT)
  51.  
  52. dim lenght
  53. lenght = 13 ' Lenght of vector (magnitude)
  54.  
  55. dim xs#(nops) ' Screen x & y location on the screen
  56. dim ys#(nops) ' Add one for last pixel
  57.  
  58. xs#(0) = 0 ' Start drawing from here
  59. ys#(0) = height / 2
  60.  
  61. dim xv#,yv#
  62.  
  63. ' Draw some lines
  64. glBegin (GL_LINES)
  65.     
  66.     for i = 0 to (nops -1)
  67.     
  68.     xv# = xs#(i) +  cosd(ang(a)) * lenght
  69.     yv# = ys#(i) +  sind(ang(a)) * lenght
  70.     
  71.     glColor3f (1, 1, 1)
  72.     glVertex2f (xs#(i),ys#(i))
  73.     glVertex2f (xv#,yv#)
  74.     
  75.     xs#(i + 1) = xv#
  76.     ys#(i + 1) = yv#
  77.     
  78.     a = a + 1 ' Progess through the angles
  79.  
  80.     next
  81.  
  82. glEnd ()
  83.  
  84. ' Display output
  85. SwapBuffers ()
  86.  
  87.